<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class user_access_level_edit extends Page
{
       public $Image1 = null;
       public $cmbSettings = null;
       public $Label6 = null;
       public $cmbRoute = null;
       public $cmbTire = null;
       public $cmbPart = null;
       public $cmbVehicle = null;
       public $Label5 = null;
       public $Label4 = null;
       public $Label2 = null;
       public $Label3 = null;
       public $Label1 = null;
       public $edLevelName = null;
       public $hfId = null;
       public $btnCancel = null;
       public $btnSubmit = null;
       function btnSubmitClick($sender, $params)
       {
       $query_update = "UPDATE accounts_access_level
       SET
       account_level='".$this->edLevelName->Text."',
       vehicle='".$this->cmbVehicle->getItemIndex()."',
       part='".$this->cmbPart->getItemIndex()."',
       tire='".$this->cmbTire->getItemIndex()."',
       route='".$this->cmbRoute->getItemIndex()."',
       settings='".$this->cmbSettings->getItemIndex()."'
       WHERE id='".$this->hfId->getValue()."'";
       if(mysql_query($query_update))
       echo "<script type='text/javascript'>
       window.opener.location.reload();
       window.close();
       </script>
       ";
       else
       die("UPDATE ACCESS LEVEL ".mysql_error());
       }

       function user_access_level_editJSUnload($sender, $params)
       {

       ?>
       window.opener.location.reload();

       <?php

       }

       function btnCancelJSClick($sender, $params)
       {

       ?>
       window.close();

       <?php

       }

       function user_access_level_editCreate($sender, $params)
       {
       $id = $_GET['access_id'];
       if($id!='' || $id!=null)
       {
        $this->hfId->setValue($id);
       }

       $query_set = "SELECT * FROM accounts_access_level WHERE id='".$this->hfId->getValue()."'";
       $result_set = mysql_query($query_set) or die("SELECT SET ".mysql_error());
       $row_set = mysql_fetch_array($result_set);

       $this->edLevelName->Text = $row_set['account_level'];
       $this->cmbVehicle->setItemIndex($row_set['vehicle']);
       $this->cmbPart->setItemIndex($row_set['part']);
       $this->cmbTire->setItemIndex($row_set['tire']);
       $this->cmbRoute->setItemIndex($row_set['route']);
       $this->cmbSettings->setItemIndex($row_set['settings']);
       }

}

global $application;

global $user_access_level_edit;

//Creates the form
$user_access_level_edit=new user_access_level_edit($application);

//Read from resource file
$user_access_level_edit->loadResource(__FILE__);

//Shows the form
$user_access_level_edit->show();

?>